#!/bin/sh

set -e

PATH_TO_SDCV="$1"
TESTS_DIR="$2"
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
cp -R "${TESTS_DIR}/rus-eng-stardict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/

unset SDCV_PAGER
export LANG=ru_RU.KOI8-R
IFS="
"
j=0
for i in `"$PATH_TO_SDCV" --utf8-input -n человек 2>&1`; do
	j=$(($j+1))
	if [ $j -ne 1 ]; then
		break;
	fi
done

if [ $j -eq 1 ]; then
	echo "$0: empty results of search: test failed" >&2
	exit 1
fi

exit 0
